#include "Processbar.h"
#include <unistd.h>

double bandwidth = 1024*1024*1.0;

//download
void download(double filesize,callback_t cb)
{
    double current = 0.0;

    printf("download begin, current: %lf\n", current);
    while(current <= filesize)
    {
        cb(filesize, current);
        //从网络中获取数据
        usleep(100000);
        current += bandwidth;
    }
    printf("\ndownload done, filesize: %lf\n",filesize);
}

int main()
{
    //printf("\033[1;31;40mHello World!\033[0m\n");
    download(100*1024*1024,ProcBar);
    download(2*1024*1024,ProcBar);
    //download(200*1024*1024,ProcBar);
    //download(400*1024*1024,ProcBar);
    //download(50*1024*1024,ProcBar);
    //download(10*1024*1024,ProcBar);
    //ForTest();
    //ProcBar();
    //ProcBar(100.0, 56.9);
    //ProcBar(100.0, 1.0);
    //ProcBar(100.0, 99.9);
    //ProcBar(100.0, 100);
    return 0;
}

